<?php

namespace Modules\WeChat\Http\Controllers;

use Illuminate\Routing\Controller;

class CommonController extends Controller
{

    /**
     *
     *
     * @return array
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function uploaded_file_onlyimg(){
        $file = $_FILES['wangEditorMobileFile'];
        $s_file_type = strtolower(explode('/',$file['type'])[1]);
        if(!in_array($s_file_type,['png','jpg','jpeg'])){
            return "error|只能上传格式为png，jpeg，jpg的图片";
        }

        $res = upload_single_file($file);
        if ( $res['state'] == 0 ) {
//            $result =  Response($res['data']['url']);
//            $result->headers["ContentType"] = "text/html";
//            $result->headers["Charset"] = "utf-8";
                    return $res['data']['url'];
        }else{
            return "error|".$res['msg'];
        }
    }

}
